package com.jsx.nativelibs.ffmpeg


class LibYUV(width: Int, height: Int) {
    fun argb2Yuv420P(argbIn: ByteArray, yuvOut: ByteArray) {
        argb2Yuv420P(context, argbIn, yuvOut)
    }

    fun destroy() {
        destroy(context)
    }

    private val context: Long

    init {
        context = init(width, height)
    }

    private external fun argb2Yuv420P(context: Long, argbIn: ByteArray, yuvOut: ByteArray)

    private external fun init(width: Int, height: Int): Long

    private external fun destroy(context: Long)

    companion object {
        init {
            System.loadLibrary("yuv")
        }

        fun testLib(): Boolean {
            val libYUV = LibYUV(0, 0)
            val context = libYUV.context
            libYUV.destroy(context)
            return context > 0
        }
    }
}
